# example7_9.py
# coding=utf-8
import pandas as pd
import numpy as np

df = pd.read_excel(
    "stock.xlsx", sheet_name="stock", index_col="Date", usecols="A:E", nrows=5
)
print("原始DataFrame对象：\n", df)
# 计算每天最高价与最低价的算术平均值
result = (df.High + df.Low) / 2
# df["mean"] = result
df["mean"] = df.apply(np.average, axis=1)
df1 = df.map(lambda x: x * 100)
print("添加平均价格后的DataFrame：\n", df)
print("所有元素乘以100:\n", df1)
